package com.example.rageclick;

import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Toast;

public class SoundsOnItemSelectedListener implements OnItemSelectedListener {

	MainActivity mainActivity;
	
	public SoundsOnItemSelectedListener(MainActivity activity) {
		mainActivity = activity;
	}
	
	public void onItemSelected(AdapterView<?> parent, View view, int pos,
			long id) {
		String selectedSound = parent.getItemAtPosition(pos).toString();
		Log.d("RageClick", "Rage is now " + selectedSound + ".");
		Toast.makeText(
				parent.getContext(),
				"Rage is now "
						+ parent.getItemAtPosition(pos).toString() + ".",
				Toast.LENGTH_SHORT).show();
		mainActivity.soundPool.unload(mainActivity.soundID);
		mainActivity.soundID = mainActivity.soundPool.load(mainActivity, MainActivity.getRawVersionOfSelectedSound(selectedSound), 1);
	}

	@Override
	public void onNothingSelected(AdapterView<?> arg0) {
		// TODO Auto-generated method stub
	}

}
